package org.csu.mybigpro.controller;

import org.csu.mybigpro.domain.LiveSession;
import org.csu.mybigpro.service.LiveSessionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/live-session")
public class LiveSessionController {
    @Autowired
    private LiveSessionService liveSessionService;

    @GetMapping("/{id}")
    public LiveSession getById(@PathVariable Long id) {
        return liveSessionService.getById(id);
    }

    @GetMapping("/list")
    public List<LiveSession> list() {
        return liveSessionService.list();
    }

    @PostMapping("/add")
    public boolean add(@RequestBody LiveSession session) {
        return liveSessionService.save(session);
    }

    @PostMapping("/update")
    public boolean update(@RequestBody LiveSession session) {
        return liveSessionService.updateById(session);
    }

    @DeleteMapping("/delete/{id}")
    public boolean delete(@PathVariable Long id) {
        return liveSessionService.removeById(id);
    }
}